package ar.edu.caece.compiler.grammar.attributes;

import ar.edu.caece.compiler.grammar.attributes.Attribute.Type;
import ar.edu.caece.compiler.grammar.attributes.tree.Generable;


public class DeclaracionVariable extends Declaracion{
	private boolean isConstante;
	private int dimension;
	private int ordenVariable;
	private boolean isParametro;
	private boolean isPorValor;
	
	public DeclaracionVariable(String nombreVariable, Type tipo,
			boolean isConstante, int dimension, int ordenVariable, boolean isParametro,boolean isPorValor) {
		super();
		this.nombreVariable = nombreVariable;
		this.tipo = tipo;
		this.isConstante = isConstante;
		this.dimension = dimension;
		this.ordenVariable = ordenVariable;
		this.isParametro = isParametro;
		this.setPorValor(isPorValor);
	}
	
	public DeclaracionVariable(String nombreVariable, Type tipo,
			boolean isConstante, int dimension, int ordenVariable) {
		super();
		this.nombreVariable = nombreVariable;
		this.tipo = tipo;
		this.isConstante = isConstante;
		this.dimension = dimension;
		this.ordenVariable = ordenVariable;
		isParametro = false;
		isPorValor = true;
	}
	
	public DeclaracionVariable(String nombreVariable, int ordenVariable) {
		super();
		this.nombreVariable = nombreVariable;
		this.ordenVariable = ordenVariable;
		isPorValor = true;
	}
	
	public boolean isLocalVariable() {
		return !isParametro;
	}
	
	public boolean isConstante() {
		return isConstante;
	}
	public void setConstante(boolean isConstante) {
		this.isConstante = isConstante;
	}
	public int getDimension() {
		return dimension;
	}
	public void setDimension(int dimension) {
		this.dimension = dimension;
	}

	@Override
	public String toString() {
		return "DeclaracionVariable [dimension=" + dimension + ", isConstante="
				+ isConstante + ", nombreVariable=" + nombreVariable
				+ ", tipo=" + tipo + ", ordenVariable/Parametro: "+ordenVariable +" ordenParametro: "+ isParametro + " variablePorValor: " + isPorValor + "]";
	}

	public void setOrdenVariable(int ordenVariable) {
		this.ordenVariable = ordenVariable;
	}

	public int getOrdenVariable() {
		return ordenVariable;
	}

	public boolean isParametro() {
		return isParametro;
	}

	public void setParametro(boolean isParametro) {
		this.isParametro = isParametro;
	}

	public void setPorValor(boolean isPorValor) {
		this.isPorValor = isPorValor;
	}

	public boolean isPorValor() {
		return isPorValor;
	}

}
